local sk__xingyun = fk.CreateSkill {

  name = "sk__xingyun",

  tags = { Skill.Compulsory, },

}



sk__xingyun:addEffect(fk.TurnEnd, {
  name = "sk__xingyun",
  anim_type = "special",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(sk__xingyun.name)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:changeMaxHp(player, -1)
    if player.dead then return end
    local skills = player:getTableMark("sk__yaozhi")
    skills = table.filter(skills, function(s)
      return not player:hasSkill(s, true)
    end)
    if #skills == 0 then return end
    local result = room:askToCustomDialog(player, {
      skill_name = "sk__xingyun",
      qml_path = "packages/utility/qml/ChooseSkillBox.qml",
      extra_data = { skills, 1, 1, "#sk__xingyun-choice" },
    })
    local skill = ""
    if result ~= "" then
      skill = result[1]
    else
      skill = table.random(skills)
    end
    room:handleAddLoseSkills(player, skill, nil, true, false)
  end,
})

return sk__xingyun
